
	Ext.onReady(function() {
		Ext.QuickTips.init();
		windowst.show();
	});

	var fielmenu = new Ext.menu.Menu({
		items : [ {
			text : '单据状况查询',
			handler : function() {
				afronction();

			}
		} ]
	});
	var fielmenu2 = new Ext.menu.Menu({
		items : [ {
			text : '采购入库单转入'
		} ]
	});
	var fielmenu3 = new Ext.menu.Menu({
		items : [ {
			text : '物料组合设定'
		}, {
			text : '批次变更单价'
		} ]
	}); 

	var grids = Ext.create('Ext.grid.Panel', {
		listeners : {
			containerdblclick : function(grid, e, eOpts) { //单击事件
				grid.getStore().add({
					'rownumberer' : '',
					'pridid' : '',
					'prodname' : '',
					'prodsize' : '',
					'sunit' : '',
					'squantity' : '',
					'oldprice' : '',
					'discount' : '',
					'sprice' : '',
					'amount' : '',
					'taxRate' : '',
					'taxAmt' : '',
					'amountatax' : '',
					'havebatch' : '',
					'hasInv' : '',
					'isgift' : '',
					'notInvCount' : '',
					'itemremark' : '',
					'trantype' : '',
					'fromno' : '',
			});

			},
			cellclick:function(grid, rowIndex, columnIndex, e){
				if(columnIndex==1){
					//Ext.Msg.alert('dd',grid+" "+rowIndex+" "+columnIndex+" "+e);
					//alert(JSON.parse(grid));
					//document.location.href="gyszwj.js";
					openWin().show();
				};
			},

	},
		plugins : [ Ext.create('Ext.grid.plugin.CellEditing', {
			clicksToEdit : 1
		}) ],
		columns : [ 
			          {header : '（栏号）',xtype : 'rownumberer',dataIndex : 'rowNo',width : 50,sortable : false}, 
			          {header : '物料编号',dataIndex : 'pridid',width : 100,editor:{xtype :'combo'}}, 
			          {header : '物料名称',dataIndex : 'prodname',width : 120,editor:{xtype :'textfield'}}, 
			          {header : '规格型号',dataIndex : 'prodsize',editor:{xtype :'textfield'}}, 
			          {header : '单位名称',dataIndex : 'sunit',editor:{xtype :'textfield'}}, 
			          {header : '数量',dataIndex : 'squantity',editor:{xtype :'textfield'}}, 
			          {header : '折扣前单价',dataIndex : 'oldprice',editor:{xtype :'textfield'}},
			          {header : '折数(%)',dataIndex : 'discount',editor:{xtype :'textfield'}}, 
			          {header : '单价',dataIndex : 'sprice',editor:{xtype :'textfield'}},
			          {header : '金额',dataIndex : 'amount',editor:{xtype :'textfield'}}, 
			          {header : '税率',dataIndex : 'taxRate',editor:{xtype :'textfield'}}, 
			          {header : '税额',dataIndex : 'taxAmt',editor:{xtype :'textfield'}}, 
			          {header : '含税金额',dataIndex : 'amountatax',editor:{xtype :'textfield'}}, 
			          {header : '批号',dataIndex : 'havebatch',editor:{xtype :'textfield'}}, 
			          {header : '发票明细',dataIndex : 'hasInv',editor:{xtype :'textfield'}},
			          {header : '赠品',dataIndex : 'isgift',editor:{xtype :'textfield'}}, 
			          {header : '未开票数量',dataIndex : 'notInvCount',editor:{xtype :'textfield'}}, 
			          {header : '分录备注',dataIndex : 'itemremark',editor:{xtype :'textfield'}},
			          {header : '来源单别',dataIndex : 'trantype',editor:{xtype :'textfield'}},
			          {header : '来源单号',dataIndex : 'fromno',editor:{xtype :'textfield'}}
		          ],
		height :95,
		width : 1980,
		autoScroll : false,
//		listeners:{
//      	  'afteredit':function(e){
//    		  Ext.Ajax.request({
//      			url:'http://localhost:8080/queryBillNo',
//      			params : {date:'2017-05-27'},
//      			method : "post",
//      			success : function(data) {
//      				alert(data);
//      			}
//      		});
//    	  }
//      }

	});
	
	

	var filterPanel = Ext.create('Ext.panel.Panel', {
		// 		bodyPadding : 0, // 避免Panel中的子元素紧邻边框
		width : 1980,
		height : 120,
		items : [ grids ],
		bbar : [ {
			xtype : "label",
			text : '总计:',
			width : 90
		}, 
		//数量合计
		{
			xtype : "textfield",
			id:"slhj",
			disabled : true,
			width : 90,
			margin : '0 180',
			value : '0.00'
		},
		//金额合计
		{
			xtype : "textfield",
			id:"jehj",
			disabled : true,
			width : 90,
			margin : '0',
			value : '0.00'
		}, 
		//税额合计
		{
			xtype : "textfield",
			id:"sehj",
			disabled : true,
			width : 90,
			margin : '0 40 0 30',
			value : '0.00'
		},
		//含税金额合计
		{
			xtype : "textfield",
			id:"hsjehj",
			disabled : true,
			width : 90,
			margin : '0 0 0 0',
			value : '0.00'
		} ],
	});

	var tableds = Ext.create('Ext.TabPanel', {
		width : "100%",
		height : 165,
		autoScroll : true,
		// 		bodyPadding : 5,
		items : [ {
			title : '内容',
			autoScroll : true,
			items : [ filterPanel ]
		}, {
			title : '备注',
			id:"bz",
			xtype : 'textarea',
			name : 'Remark',
			fieldLabel : '备注',
			labelWidth : 30,
		} ],
	});

	var formsg = Ext.create('Ext.form.Panel', {
	
		height : '80%',
		layout : "column",
		baseCls : 'x-plain',
		items : [ {
			style : 'color:blue',
			id:"cgryid",
			xtype : 'hiddenfield',
			name : "Customer",
			fieldLabel : '采购人员id',
			width : 250,
			labelWidth : 80,
			emptyText : '',
			anchor : '100%',
		},{
			style : 'margin-top:5px',
			id:"cgry",
			xtype : 'textfield',
			name : 'SalesMan',
			bodyPadding : 0,
			fieldLabel : '采购人员',
			width : 250,
			labelWidth : 80,
			anchor : '100%',
		}, {
			xtype : 'textfield',
			id:"zdry",
			name : 'Marker',
			fieldLabel : '制单人员',
			style : 'margin-top:5px;margin-left:50px',
			width : 250,
			labelWidth : 80,
			anchor : '100%',
		}, {
			style:'margin-top:5px',
			id:"ssbm",
			xtype : 'textfield',
			name : 'ProdDepart',
			fieldLabel : '所属部门',
			width : 250,
			labelWidth : 80,
			anchor : '100%',
		}, {
			xtype : 'textfield',
			id:"fhry",
			name : 'Permitter',
			fieldLabel : '复核人员',
			style : 'margin-top:5px;margin-left:50px',
			width : 250,
			labelWidth : 80,
			anchor : '100%',
		} ],
	});
	
	var payChannelStore = Ext.create('Ext.data.Store', {
        fields : [ 'id', 'shortName' ,"address" ],
        proxy : {
            type : 'ajax',
            url : 'http://localhost:8080/querySupplier',
            reader : {
                type : 'json',
                root : 'data'
            }
        },
        autoLoad : true
    });
	
	var forms = Ext.create('Ext.form.Panel', {
		bodyPadding : 12,
		height : '100%',
		layout : "column",
		baseCls : 'x-plain',
		items : [ {
			style : 'color:blue',
			id:"gys",
			xtype : 'combo',
			name : "Customer",
			fieldLabel : '供应商',
			width : 250,
			labelWidth : 80,
			emptyText : '',
			anchor : '100%',
			valueField : 'id',
            queryMode : 'local',
            displayField : 'shortName',
			store : payChannelStore,
			listeners: {  
				select : function(cbox, record) {
	                var appId = record[0].data.id;
	                Ext.getCmp('gysid').setValue(appId);
	                var address = record[0].data.address;
	                Ext.getCmp('gysdzname').setValue(address);
	                Ext.getCmp('gysdzid').setValue('');
	                orderStore.load({
                        params : {
                            start : 0,
                            limit : itemPerPage,
                            appIds : appId
                        }
                    });
				}	
			}
		},{
			style : 'color:blue',
			id:"gysid",
			xtype : 'hiddenfield',
			name : "Customer",
			fieldLabel : '供应商id',
			width : 250,
			labelWidth : 80,
			emptyText : '',
			anchor : '100%',
		}, {
			style : 'margin-left:60px;color:blue',
			id:"djrq",
			xtype : 'datefield',
			name : "BillDate",
			fieldLabel : '单据日期',
			format: 'Y-m-d',
			value: new Date(),
			width : 250,
			labelWidth : 70,
			anchor : '100%',
			listeners: 
            {
                //添加日期选择事件
              "select": function (field,value) 
              {
            	var date = Ext.getCmp('djrq').getRawValue();
            	Ext.Ajax.request({
        			url:'http://localhost:8080/queryBillNo',
        			params : {date:date},
        			method : "post",
        			success : function(data) {
        				Ext.getCmp('billNo').setValue(data.responseText);
        			}
        		});
              }
            }
		}, {
			xtype : 'textfield',
			id:"gysdzid",
			name : "DeliveryAddress",
			fieldLabel : '供应商地址',
			width : 150,
			labelWidth : 80,
			anchor : '100%'
		}, {
			xtype : 'textfield',
			id:"gysdzname",
			name : "dizhiton",
			width : 99,
			labelWidth : 70,
			margin : "0 1",
			anchor : '100%',
		}, {
			style : 'margin-left:60px;color:blue;',
			id:"billNo",
			xtype : 'textfield',
			//xtype : 'numberfield'
			name : "BillNo",
			fieldLabel : '单据号码',
			width : 250,
			labelWidth : 70,
			anchor : '100%',
		}, {
			fieldLabel : '单价是否含税',
			id:"sfhs",
			xtype : 'combo',
			name : "IncludeRate",
			displayField : 'name',
			labelWidth : 80,
			width : 250,
			valueField : 'abbr',
			store : Ext.create('Ext.data.Store', {
				fields : [ 'abbr', 'name' ],
				data : [ {
					"abbr" : "含税",
					"name" : "含税"
				}, {
					"abbr" : "未税",
					"name" : "未税"
				}

				]
			}),
			value : '含税',
			typeAhead : true,
			mode : 'local',
			triggerAction : 'all',
			selectOnFocus : true,

		}, {
			style : 'margin-left:60px',
			id:"bj",
			xtype : 'textfield',
			name : "MoneyStyle",
			fieldLabel : '币别',
			labelWidth : 70,
			width : 250,
			anchor : '100%',
		},{
			style : 'color:blue',
			id:"ckid",
			xtype : 'hiddenfield',
			name : "Customer",
			fieldLabel : '仓库id',
			width : 250,
			labelWidth : 80,
			emptyText : '',
			anchor : '100%',
		}, {
			xtype : 'textfield',
			id:"ck",
			name : "Ware",
			fieldLabel : '仓库',
			width : 250,
			style : "color:blue",
			labelWidth : 80,
			anchor : '100%'
		}, {
			style : 'margin-left:60px',
			id:"hl",
			xtype : 'textfield',
			name : "huilv",
			fieldLabel : '汇率',
			labelWidth : 70,
			width : 250,
			anchor : '100%',
		}, { 
			fieldLabel : '是否重新入库',
			id:"sfcxrk",
			xtype : 'combo',
			name : "IncludeRate",
			displayField : 'name',
			labelWidth : 80,
			width : 250,
			valueField : 'abbr',
			store : Ext.create('Ext.data.Store', {
				fields : [ 'abbr', 'name' ],
				data : [ {
					"abbr" : "是",
					"name" : "是"
				}, {
					"abbr" : "否",
					"name" : "否"
				}

				]
			}),
			value : '否',
			typeAhead : true,
			mode : 'local',
			triggerAction : 'all',
			selectOnFocus : true,
		}, {
			fieldLabel : '国外贸易',
			id:"gwmy",
			xtype : 'combo',
			name : 'guowaimaoyi',
			style : "margin-left:60px",
			displayField : 'name',
			labelWidth : 70,
			width : 250,
			disabled : true,
			valueField : 'abbr',
			store : Ext.create('Ext.data.Store', {
				fields : [ 'abbr', 'name' ],
				data : [ {
					"abbr" : "是",
					"name" : "是"
				}, {
					"abbr" : "否",
					"name" : "否"
				}

				]
			}),
			value : '否',
			typeAhead : true,
			mode : 'local',
			triggerAction : 'all',
			selectOnFocus : true,
		}, {
			xtype : 'textfield',
			id:"pzdh",
			name : "ProveBillNo",
			fieldLabel : '凭证单号',
			width : 250,
			disabled : true,
			labelWidth : 80,
			anchor : '100%',
		},{
			style : 'color:blue',
			id:"zta",
			xtype : 'hiddenfield',
			name : "zta",
			fieldLabel : '状态',
			width : 250,
			labelWidth : 80,
			emptyText : '',
			anchor : '100%',
		}, tableds, formsg

		]
	});
	
	// 查询冲款主表
	var datas;
	var datas1;
	query(0);
	function query(id){
		Ext.Ajax.request({
			url : "http://localhost:8080/queryBuy",
			params : {currentPage:id},
			method : "post",
			success : function(data) {
				if(data==""){
					Ext.MessageBox.alert("提示","目前没有退货单据！！！",function(){});
				}
				else{
					var temp=JSON.parse(data.responseText);
					datas1=temp.pageobj[0];
					datas=temp;
					fulldata(datas1)
				}
			},
		});
	}
	
	function fulldata(temp){
		Ext.getCmp('billNo').setValue(temp.billNo);
		Ext.getCmp('gys').setValue(temp.custName);
		
		//供应商id
		Ext.getCmp('gysid').setValue(temp.custNo );
		
		Ext.getCmp('gysdzid').setValue(temp.addrId );
		Ext.getCmp('gysdzname').setValue(temp.custAddress);
		Ext.getCmp('sfhs').setValue(temp.priceoftax);
		
		//仓库id
		Ext.getCmp('ckid').setValue(temp.wareId );
		
		Ext.getCmp('ck').setValue(temp.wareName);
		Ext.getCmp('sfcxrk').setValue(temp.isDeduct);
		Ext.getCmp('pzdh').setValue(temp.coucherno);
		Ext.getCmp('djrq').setValue(temp.billDate);
		Ext.getCmp('bj').setValue(temp.currId);
		Ext.getCmp('hl').setValue(temp.exchRate);
		Ext.getCmp('gwmy').setValue(temp.hasForeignTrade);
		
		Ext.getCmp('bz').setValue(temp.remarks );

		//采购人员id
		Ext.getCmp('cgryid').setValue(temp.salesNo);
		
		Ext.getCmp('cgry').setValue(temp.salesName);
		Ext.getCmp('zdry').setValue(temp.maker );
		Ext.getCmp('ssbm').setValue(temp.departName );
		Ext.getCmp('fhry').setValue(temp.permitter );
		
		Ext.getCmp('slhj').setValue(temp.sumNum );
		Ext.getCmp('jehj').setValue(temp.total  );
		Ext.getCmp('sehj').setValue(temp.tax  );
		Ext.getCmp('hsjehj').setValue(temp.sumAmtATax  );
		
		grids.getStore().add(temp.info);
		
	}
		
	function add(status,del,btn){
			//var state="";
			Ext.Ajax.request({
				url:'http://localhost:8080/querySatus',
				async:true,
				params : {billNo:Ext.getCmp('billNo').getValue()},
				method : "post",
				success : function(data) {
					//zta
					state = data.responseText;
					Ext.getCmp('zta').setValue(state);
					
					if(Ext.getCmp('gys').getValue()==""){
						Ext.MessageBox.alert("提示","请选择供应商",function(){});
						return;
					}else if(Ext.getCmp('ck').getValue()==""){
						Ext.MessageBox.alert("提示","请选择仓库",function(){});
						return;
					}else if(Ext.getCmp('billNo').getValue()==""){
						Ext.MessageBox.alert("提示","单据号码不能为空",function(){});
						return;
					}else if(btn=="反审核"){
						if(Ext.getCmp('zta').getValue()!="已审核"){
							Ext.MessageBox.alert("提示","单据未审核,不能进行该操作",function(){});
							return;
						}
					}else if(btn!="反审核"){
						if(Ext.getCmp('zta').getValue()=="已审核"){
							Ext.MessageBox.alert("提示","单据已审核,不能进行该操作",function(){});
							return;
						}
					}
//					else if(state=="已审核"){
//						alert(state);
//						alert(btn);
//						if(btn=="反审核"){
//							//Ext.MessageBox.alert("提示","单据已审核,不能进行该操作",function(){});
//						}else{
//							Ext.MessageBox.alert("提示","单据已审核,不能进行该操作",function(){});
//							return;
//						}
//					}
		        	var purchase={};
		        	purchase["billNo"] = Ext.getCmp('billNo').getValue();
		        	
		        	purchase["custNo"] = Ext.getCmp('gysid').getValue();
		        	
		        	purchase["custName"] = Ext.getCmp('gys').getValue();
		        	purchase["addrId"] = Ext.getCmp('gysdzid').getValue();
		        	purchase["custAddress"] = Ext.getCmp('gysdzname').getValue();
		        	purchase["priceoftax"] = Ext.getCmp('sfhs').getValue();
		        	
		        	purchase["wareId"] = Ext.getCmp('ckid').getValue();
		        	
					purchase["wareName"] = Ext.getCmp('ck').getValue();
					purchase["isDeduct"] = Ext.getCmp('sfcxrk').getValue();
					purchase["coucherno"] = Ext.getCmp('pzdh').getValue();
					purchase["billDate"] = Ext.getCmp('djrq').getValue();
					purchase["currId"] = Ext.getCmp('bj').getValue();
					purchase["exchRate"] = Ext.getCmp('hl').getValue();
					purchase["hasForeignTrade"] = Ext.getCmp('gwmy').getValue();
					
					purchase["remarks"] = Ext.getCmp('bz').getValue();
					
					purchase["salesNo"] = Ext.getCmp('cgryid').getValue();
					
					purchase["salesName"] = Ext.getCmp('cgry').getValue();
					purchase["maker"] = Ext.getCmp('zdry').getValue();
					purchase["departName"] = Ext.getCmp('ssbm').getValue();
					purchase["permitter"] 	= Ext.getCmp('fhry').getValue();
					
					purchase["sumNum"] = Ext.getCmp('slhj').getValue();
					purchase["total"] = Ext.getCmp('jehj').getValue();
					purchase["tax"] = Ext.getCmp('sehj').getValue();
					purchase["sumAmtATax"] = Ext.getCmp('hsjehj').getValue();
					
					purchase["billStatus"] 	= status;
					purchase["isDelete"] 	= del;
					
					purchase["info"] = Ext.pluck(grids.getStore().data.items,"data"),
					
		           // alert(JSON.stringify(purchase));
		            
					Ext.Ajax.request({
						url:'http://localhost:8080/insertPurchaseReturn',
						headers:{"Content-Type":"application/json"},
						params:JSON.stringify(purchase),
						success:function(response){
							if(btn=="审核"){
								var money = Ext.getCmp('jehj').getValue();
								var gysid = Ext.getCmp('gysid').getValue();
								upSup(money,gysid,btn);
								
							}else if(btn=="反审核"){
								var money = 0-Ext.getCmp('jehj').getValue();
								var gysid = Ext.getCmp('gysid').getValue();
								upSup(money,gysid,btn);						
							}else{
								Ext.MessageBox.alert("提示","处理成功",function(){});
							}
						}
					});
					
					
				}
			});
			//alert(Ext.getCmp('zta').getValue()+"1");
			
	}
	
	function clearText(){
		Ext.getCmp('djrq').setValue(new Date());
    	Ext.Ajax.request({
			url:'http://localhost:8080/queryBillNo',
			//headers:{"Content-Type":"application/json"},
			params : {date:Ext.getCmp('djrq').getRawValue()},
			method : "post",
			success : function(data) {
				var billNo = JSON.parse(data.responseText);
				Ext.getCmp('billNo').setValue(billNo);
			}
		});
    	
    	Ext.getCmp('gys').setValue("");
		
		//供应商id
		Ext.getCmp('gysid').setValue("");
		
		Ext.getCmp('gysdzid').setValue("");
		Ext.getCmp('gysdzname').setValue("");
		Ext.getCmp('sfhs').setValue("未税");
		
		//仓库id
		Ext.getCmp('ckid').setValue("");
		
		Ext.getCmp('ck').setValue("");
		Ext.getCmp('sfcxrk').setValue("否");
		Ext.getCmp('pzdh').setValue("");
		Ext.getCmp('bj').setValue("");
		Ext.getCmp('hl').setValue("");
		Ext.getCmp('gwmy').setValue("否");
		
		Ext.getCmp('bz').setValue("");

		//采购人员id
		Ext.getCmp('cgryid').setValue("");
		
		Ext.getCmp('cgry').setValue("");
		Ext.getCmp('zdry').setValue("");
		Ext.getCmp('ssbm').setValue("");
		Ext.getCmp('fhry').setValue("");
		
		Ext.getCmp('slhj').setValue("");
		Ext.getCmp('jehj').setValue("");
		Ext.getCmp('sehj').setValue("");
		Ext.getCmp('hsjehj').setValue("");
		
		grids.getStore().removeAll();//清空grid所有数据
		
	}
	
	var gysgrid = Ext.create('Ext.grid.Panel', {
		columns : [ 
				{header: '供应商编号', dataIndex: 'id',width:100},
				{header: '供应商简称', dataIndex: 'shortName'}
		          ],
		store : payChannelStore,
		 height: 200,
		 width: 300,
		autoScroll : false,

	});
	
	var wlStore = Ext.create('Ext.data.Store', {
        fields : [ 'prodId','prodName' ],
        proxy : {
            type : 'ajax',
            url : 'http://localhost:8080/Product',
            reader : {
                type : 'json',
                root : 'data'
            }
        },
        autoLoad : true
    });
	
	var wlgrid = Ext.create('Ext.grid.Panel', {
		columns : [ 
				{header: '物料编号', dataIndex: 'prodId',width:150},
				{header: '物料名称', dataIndex: 'prodName',width:150}
		          ],
		store : wlStore,
		 height: 300,
		 width: 400,
		autoScroll : false,

	});
	function openWin(){
			return a=Ext.getCmp('open1')?a:Ext.create('Ext.window.Window',{
				id:'xzgys',
			    title: '单选供应商主文件',
			    height: 320,
			    width:420,
			    layout: 'fit',
			    closeAction: 'close',
			    items: [wlgrid],
			    dockedItems: [{
				    xtype: 'toolbar',
				    dock: 'top',
				    items: [
				        { xtype: 'button', text: '全选',handler: function() {}},
				        { xtype: 'button', text: '全清',handler: function() {}},
				        { xtype: 'button', text: '以下全选',handler: function() {}},
				        { xtype: 'button', text: '以下全清',handler: function() {}},
				        { xtype: 'button', text: '取回',handler: function() {
				        	alert(11);
				        	var row = wlgrid.getSelectionModel().getSelection();
				        	if (row.length == 0) {  
				        	    Ext.Msg.alert("提示信息", "您没有选中行!");  
				        	}else{
				        		var id = row[0].data.prodId;
				        		Ext.Ajax.request({
									url:'http://localhost:8080/selectId',
									params : {id:id},
									method : "post",
									//headers:{"Content-Type":"application/json"},
									success:function(response){
										var temp = JSON.parse(response.responseText);
										grids.getStore().add(temp);
										alert(temp);
									}
								});
				        		
				        	}
				        }},
				        ]
			    }],
			    listeners:{
			    	activate:function(){
			    		//gysgrid.getStore.add(payChannelStore.data);
			    	}
			    },
			});
	}
	
	
	function upSup(money,gysid,cz){
		Ext.Ajax.request({
			url:'http://localhost:8080/updateSupplier',
			//headers:{"Content-Type":"application/json"},
			params : {money:money,id:gysid},//Ext.getCmp('jehj').getValue(),id:Ext.getCmp('gysid').getValue()},
			method : "post",
			success : function(data) {
				//Ext.MessageBox.alert("提示","处理成功！！！",function(){});
				//upPro(num,money,proId);
				var rowCount = grids.getStore().getCount();
				var data;
				if(cz=="审核"){
					for(var i = 0;i<rowCount;i++){
						//pridid,squantity,amount
						data = grids.getStore().getAt(i).data;
						//alert(data.pridid);
						upPro(data.squantity,data.amount,data.pridid)
					}
				}else if(cz=="反审核"){
					for(var i = 0;i<rowCount;i++){
						//pridid,squantity,amount
						data = grids.getStore().getAt(i).data;
						//alert(data.pridid);
						upPro(0-data.squantity,0-data.amount,data.pridid)
					}
				}
			}
		});
	}
	
	function upPro(num,money,proId){
		Ext.Ajax.request({
			url:'http://localhost:8080/updateProduct',
			//headers:{"Content-Type":"application/json"},
			params : {num:num,money:money,id:proId},//Ext.getCmp('jehj').getValue(),id:Ext.getCmp('gysid').getValue()},
			method : "post",
			success : function(data) {
				Ext.MessageBox.alert("提示","处理成功！！！",function(){});
			}
		});
	}
	
	var windowst = new Ext.Window({
		width : 600,
		height : 510,
		title : "采购退货单",
		closable : true,
		resizable : false, //设置是否可以改变大小
		draggable : true,
		anchor : '100%',
		items : [ forms ],
		dockedItems: [{
		    xtype: 'toolbar',
		    dock: 'top',
		    
		    items: [
		        { xtype: 'button', text: '新增',handler: function() {
		        	clearText();
		        }},
		        { xtype: 'button', text: '保存' ,handler: function() {
		        	add("未审核","否","保存");
		        	//query(datas.topPage);
	    			//grids.getStore().removeAll();
		        }},
		        { xtype: 'button', text: '修改' ,handler: function() {
		        	Ext.MessageBox.alert("提示","你在点击修改按钮！！！",function(){});
		        }},
		        { xtype: 'button', text: ''  },
		        { xtype: 'button', text: '审核'  ,handler: function() {
		        	add("已审核","否","审核");
		        	//upSup();
		        	//query(datas.topPage);
		        	//upSup();
	    			//grids.getStore().removeAll();
		        }},
		        { xtype: 'button', text: '反审核',handler: function() {
		        	add("未审核","否","反审核");
		        }},
		        { xtype: 'button', text: ' ' },
		        { xtype: 'button', text: '刷新' ,handler: function() {
		        	query(0);
		        	Ext.MessageBox.alert("提示","你在点击刷新按钮！！！",function(){});
		        }},
		        { xtype: 'button', text: '放弃' ,handler: function() {
		        	windowst.show();
		        	Ext.MessageBox.alert("提示","你在点击放弃按钮！！！",function(){});
		        }},
		        { xtype: 'button', text: '删除' ,handler: function() {
		        	add("未审核","是","删除");
		        }},
		        { xtype: 'button', text: '' },
		        { xtype: 'button', text: '第一条' ,handler : function() {
		        	query(0);
	    			grids.getStore().removeAll();
	    		}},
		        { xtype: 'button', text: '上一条' ,handler : function() {
	    			if(datas.currentPage<datas.topPage){
	    				Ext.MessageBox.alert("提示","您正在浏览第一条数据!!!",function(){});
	    				return;
	    			}
	    			query(datas.topPage);
	    			grids.getStore().removeAll();
	    		}},
		        { xtype: 'button', text: '下一条' ,
		    		handler : function() {
		    			if(datas.nextPage>datas.pagesize-1){
		    				Ext.MessageBox.alert("提示","您正在浏览最后一条数据!!!",function(){});
		    				return;
		    			}
		    			query(datas.nextPage);
		    			grids.getStore().removeAll();
		    		}},
		        { xtype: 'button', text: '最后一条'  ,handler : function() {
		        	query(datas.pagesize-1);
	    			grids.getStore().removeAll();
	    		}}
		    ]
		}],
		bbar : [ {
			xtype : "splitbutton",
			text : '查询',
			width : 90,
			menu : fielmenu
		}, {
			xtype : "splitbutton",
			text : '转单',
			width : 90,
			menu : fielmenu2
		}, {
			xtype : "splitbutton",
			text : '功能',
			width : 90,
			menu : fielmenu3
		} ],
	});

